home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / vcafe / samples.bin / ThreadX.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-09-04  |  2.8 KB  |  92 lines

  1. import java.applet.Applet;
  2. import java.awt.BorderLayout;
  3. import java.awt.Button;
  4. import java.awt.Color;
  5. import java.awt.Container;
  6. import java.awt.Event;
  7. import java.awt.FlowLayout;
  8. import java.awt.GridLayout;
  9. import java.awt.Label;
  10. import java.awt.Panel;
  11.  
  12. public class ThreadX extends Applet {
  13.    AnimationPanel panelOne;
  14.    AnimationPanel panelTwo;
  15.    AnimationPanel panelThree;
  16.    Panel animationArea;
  17.    Panel mainButtonPanel;
  18.    Button aStartButton;
  19.    Button aStopButton;
  20.    Button resetButton;
  21.    Label label1;
  22.  
  23.    public void init() {
  24.       ((Container)this).setLayout(new BorderLayout(0, 0));
  25.       ((Panel)this).addNotify();
  26.       ((Applet)this).resize(500, 280);
  27.       this.animationArea = new Panel();
  28.       this.animationArea.setLayout(new FlowLayout(1, 5, 5));
  29.       this.animationArea.resize(this.animationArea.preferredSize());
  30.       this.animationArea.move(28, 6);
  31.       ((Container)this).add("Center", this.animationArea);
  32.       this.mainButtonPanel = new Panel();
  33.       this.mainButtonPanel.setLayout(new FlowLayout(1, 5, 5));
  34.       this.mainButtonPanel.resize(this.mainButtonPanel.preferredSize());
  35.       this.mainButtonPanel.move(28, 172);
  36.       ((Container)this).add("South", this.mainButtonPanel);
  37.       this.aStartButton = new Button("All Start");
  38.       this.aStartButton.resize(this.aStartButton.preferredSize());
  39.       this.aStartButton.move(76, 200);
  40.       this.mainButtonPanel.add(this.aStartButton);
  41.       this.aStopButton = new Button("All Stop");
  42.       this.aStopButton.resize(this.aStopButton.preferredSize());
  43.       this.aStopButton.move(198, 200);
  44.       this.mainButtonPanel.add(this.aStopButton);
  45.       this.resetButton = new Button("Reset");
  46.       this.resetButton.resize(this.resetButton.preferredSize());
  47.       this.resetButton.move(318, 200);
  48.       this.mainButtonPanel.add(this.resetButton);
  49.       this.label1 = new Label("label");
  50.       this.label1.reshape(262, 110, 103, 49);
  51.       ((Container)this).add(this.label1);
  52.       this.animationArea.setLayout(new GridLayout(1, 3));
  53.       this.animationArea.add(this.panelOne = new AnimationPanel(Color.red, 75));
  54.       this.animationArea.add(this.panelTwo = new AnimationPanel(Color.white, 100));
  55.       this.animationArea.add(this.panelThree = new AnimationPanel(Color.blue, 125));
  56.       super.init();
  57.    }
  58.  
  59.    public boolean handleEvent(Event event) {
  60.       if (event.id == 1001 && event.target == this.resetButton) {
  61.          this.Reset();
  62.          return true;
  63.       } else if (event.id == 1001 && event.target == this.aStopButton) {
  64.          this.AllStop();
  65.          return true;
  66.       } else if (event.id == 1001 && event.target == this.aStartButton) {
  67.          this.AllStart();
  68.          return true;
  69.       } else {
  70.          return super.handleEvent(event);
  71.       }
  72.    }
  73.  
  74.    public void AllStart() {
  75.       this.panelOne.StartAnimation();
  76.       this.panelTwo.StartAnimation();
  77.       this.panelThree.StartAnimation();
  78.    }
  79.  
  80.    public void AllStop() {
  81.       this.panelOne.StopAnimation();
  82.       this.panelTwo.StopAnimation();
  83.       this.panelThree.StopAnimation();
  84.    }
  85.  
  86.    public void Reset() {
  87.       this.panelOne.ResetAnimation();
  88.       this.panelTwo.ResetAnimation();
  89.       this.panelThree.ResetAnimation();
  90.    }
  91. }
  92.